package xyx.ysfwpt.service;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;
import xyx.ysfwpt.dao.DrugDao;
import xyx.ysfwpt.model.Drug;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("DrugService")
public class DrugServiceImpl implements DrugService{
    @Resource
    DrugDao drugDao;

    @Override
    public List<Drug> selectAllDrug(){
        return drugDao.selectAllDrug();
    }

    public List<Drug> selectDrugByInputList(@Param(value = "hospital") String hospital,
                                            @Param(value = "delivery") String delivery,
                                            @Param(value = "searchword") String searchword){
        return drugDao.selectDrugByInputList(hospital,delivery,searchword);
    }

    public void addDrug(Drug drug){
        drugDao.addDrug(drug);
    }

    public void deleteDrug(int drug_id){
        drugDao.deleteDrug(drug_id);
    }

    public Drug selectDrugByDrugId(int drug_id){
        return drugDao.selectDrugByDrugId(drug_id);
    }

    public void updateDrug(Drug drug){
        drugDao.updateDrug(drug);
    }

    public List<Map> selectDrugConsume(@Param(value = "manufacturer") String manufacturer,
                                       @Param(value = "searchword") String searchword){
        return drugDao.selectDrugConsume(manufacturer,searchword);
    }

}
